import { cookies, headers } from 'next/headers'
import { isMobile } from '../../utils'
import Provider from './components/Provider'
import Main from './_main'
import { getTemplateByMid } from '@/service'

export default async function Page(props: any) {
  const { searchParams } = props
  const headersList = headers()
  const userAgent = headersList.get('user-agent')
  const mobile = isMobile(userAgent)
  const { id, mid } = searchParams
  let data = null
  const myResumes = []
  try {
    data = await getTemplateByMid({ id: mid })
  }
  catch (e) {
    console.log(e);
  }
  return (<Provider data={data} {...searchParams} myResumes={myResumes} isMobile={mobile}>
    <Main></Main>
  </Provider>
  )
}
